<template>
    <!--<div class="floor-ad" v-if="ad">-->
    <!--<img v-lazy="ad.adv_code" @click="goAdUrl(ad)"/>-->
    <!--</div>-->
    <div v-if="ad" class="index-myself-list" @click="goAdUrl(ad)">
        <div class="index-myself-title">- {{ad.adv_title}} -</div>
        <img class="index-myself-pic" :src="ad.adv_code">
    </div>
</template>

<script>
    export default {
        name: 'IndexFloorAds',
        data() {
            return {}
        },
        props: ['ad'],
        methods: {
            goAdUrl(item) {
                switch (item.adv_type) {
                    case 'goods':
                        this.$router.push({name: 'HomeGoodsdetail', query: {goods_id: item.adv_typedate}})
                        break
                    case 'store':
                        this.$router.push({name: 'HomeStoredetail', query: {id: item.adv_typedate}})
                        break
                    case 'article':
                        this.$router.push({name: 'HomeArticledetail', query: {article_id: item.adv_typedate}})
                        break
                    case 'url':
                        window.location.href = item.adv_typedate
                        break
                    case 'classes':
                        this.$router.push({'name': 'HomeGoodslist', query: {cate_id: item.adv_typedate}})
                        break
                    case 'group':
                        this.$router.push({ 'name': 'HomePintuanList' })
                        break
                    case 'price':
                        this.$router.push({ 'name': 'HomeBargainlist' })
                        break
                }
            }
        }
    }
</script>

<style scoped>
    .index-myself-list {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 1rem .5rem;
        background: white;
    }

    .index-myself-title {
        font-size: .7rem;
        font-weight: bold;
    }

    .index-myself-pic {
        margin-top: 0.7rem;
        width: 100%;
        height: auto;
    }
</style>
